package com.example.neusoft215gdh.androidpro_21.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.neusoft215gdh.androidpro_21.JavaBean.Contest;
import com.example.neusoft215gdh.androidpro_21.Listener.ContestDetailListener;
import com.example.neusoft215gdh.androidpro_21.Model.ContestModel;
import com.example.neusoft215gdh.androidpro_21.R;
import com.squareup.picasso.Picasso;

/**
 * Created by Rainbow on 2017/11/11.
 */

public class ContestActivity extends AppCompatActivity implements ContestDetailListener,View.OnClickListener {
    Intent intent;
    String Picid;
    TextView contest_name;
    TextView contest_total;
    TextView contest_time;
    TextView contest_intro;
    ImageView reg_return11;
    ImageView contestPic1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contest_detail);
        intent=getIntent();
        Picid=intent.getStringExtra("id");
         initView();
        ContestModel contestModel=new ContestModel();
        contestModel.getMatchById(Picid,this);
        reg_return11.setOnClickListener(this);
        }

    public void  initView(){
        contest_name= (TextView) findViewById(R.id.contest_name);
        contest_time= (TextView) findViewById(R.id.contest_time);
        contest_intro= (TextView) findViewById(R.id.contest_intro);
        contest_total= (TextView) findViewById(R.id.contest_total);
        reg_return11= (ImageView) findViewById(R.id.reg_return11);
        contestPic1= (ImageView) findViewById(R.id.contestPic1);
    }

    @Override
    public void onResponse(Contest bean) {
        contest_name.setText(bean.getName());
        contest_total.setText(bean.getHits());
        contest_time.setText(bean.getUpdate_time());
        contest_intro.setText(bean.getIntroduction());
        if(!bean.getThumb().isEmpty())
        {
            Picasso.with(this).load("http://172.24.10.175/workout/Uploads/"+bean.getThumb()).into(contestPic1);
        }
        else
        {
            contestPic1.setImageResource(R.drawable.ic_person);
        }
    }

    @Override
    public void onFail(String msg) {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.reg_return11:
                finish();
                break;
        }
    }
}
